package org.example.im.client.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.example.im.bean.protocol.response.LeaveGroupResponsePacket;
import org.springframework.stereotype.Component;

/**
 * @author dingrui
 * @since 2022/2/12
 * @description 退群
 */
@Component
public class LeaveGroupHandler extends SimpleChannelInboundHandler<LeaveGroupResponsePacket> {

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, LeaveGroupResponsePacket leaveGroupResponsePacket) throws Exception {
        String groupId = leaveGroupResponsePacket.getGroupId();
        if (leaveGroupResponsePacket.isSuccess())
            System.out.println("[C-LeaveGroup] 退群[{" + groupId + "}]成功");
        else
            System.out.println("[C-LeaveGroup] 退群[{" + groupId + "}]失败 详情: " + leaveGroupResponsePacket.getMsg());
    }
}
